import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/* Sean, Matt McGee, Trent, Kayla
 * 
 * 
 */



public class GUI{
	public static GridLayout regular = new GridLayout(5, 2, 5, 5);
	public static void main(String[] args){
		
		//main
		
		optionGUI(regular);
		
	}
	
	public static void personGUI(GridLayout person){
		final JTextField fn = new JTextField();
		final JTextField ln = new JTextField();
		final JTextField ssn = new JTextField();
		final JTextField age = new JTextField();
		
		
		
		
		
		final JFrame frame = new JFrame();
		frame.setSize(750, 375);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(person);
		try{
		frame.add(new JLabel("First name"));
		frame.add(fn);
		
		
		
		frame.add(new JLabel("Last name"));
		frame.add(ln);
		
		frame.add(new JLabel("SSN name"));
		frame.add(ssn);
		
		frame.add(new JLabel("Age"));
		frame.add(age);
		frame.pack();
		} catch( NumberFormatException e){
			 JOptionPane.showConfirmDialog(null, "Please enter numbers only");
		}
		
		JButton submit = new JButton("Submit");
		frame.add(submit);
		JButton cancel = new JButton("Cancel");
		frame.add(cancel);
submit.addActionListener(new ActionListener(){
			
			public void actionPerformed(ActionEvent e){
				String fntxt = fn.getText();
				String lntxt = ln.getText();
				String ssntxt = ssn.getText();
				String agetxt = age.getText();
				
				
				System.out.println("Person's name is " + fntxt + " " + lntxt);
				System.out.println(fntxt + "'s social is " + ssntxt);
				System.out.println(fntxt + "'s age is " + agetxt);
				
				
				
				
				
				
				
			}
				
				
			
		});
		cancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				
				optionGUI(regular);
				frame.setVisible(false);
			}
		});
		
	
		
		
		
		
		
	}
	public static void studentGUI(GridLayout student){
		final JTextField SID = new JTextField();
		final JTextField gpa = new JTextField(10);
		final JTextField adv = new JTextField(10);
		
		
		
		final JFrame frame = new JFrame();
		frame.setSize(750, 375);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(student);
		frame.add(new JLabel("ID"));
		
		frame.add(SID);
		
		frame.add(new JLabel("GPA"));
		frame.add(gpa);
		
		frame.add(new JLabel("Advisor"));
		frame.add(adv);
		
		
		JButton submit = new JButton("Submit");
		frame.add(submit);
		JButton cancel = new JButton("Cancel");
		frame.add(cancel);
		frame.pack();
		submit.addActionListener(new ActionListener(){
			
			public void actionPerformed(ActionEvent e){
				String gpatxt = gpa.getText();
				String advtxt = adv.getText();
				String SIDtxt = SID.getText();
				System.out.println("Student ID is: " + SIDtxt);
				System.out.println("student gpa is: " + gpatxt);
				System.out.println("Student Advisor is: " + advtxt);
			}
				
				
			
		});
		cancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				optionGUI(regular);
				frame.setVisible(false);
				
			}
		});
		
		
	}
	public static void employeeGUI(GridLayout empl){
		final JTextField sal = new JTextField(10);
		final JTextField sup = new JTextField(10);
		final JTextField ID = new JTextField(10);
		final JFrame frame = new JFrame();
		frame.setSize(750, 375);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(empl);
		frame.add(new JLabel("Employee ID"));
		frame.add(ID);
		
		frame.add(new JLabel("Salary"));
		frame.add(sal);
		
		
		frame.add(new JLabel("Supervisor"));
		frame.add(sup);
		frame.pack();
		
		JButton submit = new JButton("Submit");
		frame.add(submit);
		JButton cancel = new JButton("Cancel");
		frame.add(cancel);
		
		submit.addActionListener(new ActionListener(){
			
			public void actionPerformed(ActionEvent e){
				String IDtxt = ID.getText();
				String suptxt = sup.getText();
				String saltxt = sal.getText();
				System.out.println("My ID is: " + IDtxt);
				System.out.println("My salary is: " + saltxt);
				System.out.println("My supervisor is: " + suptxt);
				
				
				
				
			}
				
				
			
		});
		cancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				
				optionGUI(regular);
				frame.setVisible(false);
			}
		});
		
	}
	
	public static void optionGUI(GridLayout option){
		
		final JRadioButton stubtn = new JRadioButton("Student", false);
		final JRadioButton empbtn = new JRadioButton("Employee", false);
		final JRadioButton perbtn = new JRadioButton("Person", false);
		
		final JFrame opframe = new JFrame();
		opframe.setSize(750, 375);
		
		opframe.setVisible(true);
		opframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		opframe.setLayout(option);
		opframe.add(stubtn);
		opframe.add(empbtn);
		opframe.add(perbtn);
		
		JButton submit = new JButton("Submit");
		opframe.add(submit);
		JButton cancel = new JButton("Cancel");
		opframe.add(cancel);
		opframe.pack();
		
		submit.addActionListener(new ActionListener(){
			
			public void actionPerformed(ActionEvent e){
					if(stubtn.isSelected()){
						studentGUI(regular);
						opframe.setVisible(false);
						
					}
					else if(empbtn.isSelected()){
						employeeGUI(regular);
						opframe.setVisible(false);
					}
					else if(perbtn.isSelected()){
						personGUI(regular);
						opframe.setVisible(false);
						
					}
					else{
						JOptionPane.showMessageDialog(null, "Please choose one.");
					}
					
				}
				
				
			
		});
		cancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			System.exit(-1);
			}
		});
		

	}


}


